package com.gw.business.common.constant;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import com.gw.platform.model.UserModel;

/**
 * 
 * 类功能:全局变量定义
 * 
  * <p>
 * 创建者:关博
 * </p>
 * 
 * <p>
 * 创建时间:2014-06-23
 * </p>
 * 
 * <p>
 * 修改者:
 * </p>
 * 
 * <p>
 * 修改时间:
 * </p>
 * 
 * <p>
 * 修改原因：
 * </p>
 * 
 * <p>
 * 审核者:
 * </p>
 * 
 * <p>
 * 审核时间:
 * </p>
 * 
 * <p>
 * 审核意见：
 * </p>
 */
public class GlobalConstant {
	/**
	 * 员工标识 会话中key
	 */
	public static final String SESSION_USER="session_user";
	
	/**
	 * 错误信息
	 */
	public static String ERROR_MESSAGE = "errorMessage";
	
	/**
	 * 系统菜单信息
	 */
	public static List SYSTEM_MENU ;
	
	/**
	 * 获取当前登录用户
	 * @return
	 */
	public static UserModel getSessionUser(){
		try {
			ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
			return (UserModel) attr.getRequest().getSession().getAttribute(SESSION_USER);
		} catch (Exception e) {
			return null;
		}
	}
	
	/**
	 * 获取访问路径
	 * @return
	 */
	public static String getFullPath(){
		try {
			ServletRequestAttributes attr = (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
			HttpServletRequest request =  attr.getRequest();
			String rootPath = request.getContextPath();
			
			
			
			
			String fullPath = request.getScheme() + "://"
						+ request.getServerName() + ":" + request.getServerPort()
						+ rootPath + "/";
			
			return fullPath;
		} catch (Exception e) {
			return "";
		}
	}
}
